#!/bin/bash

# Copyright 2019 The OpenSDS Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

cd ../..
BASE_DIR=`pwd` 
apt-get update && apt-get install -y make wget sudo
wget https://storage.googleapis.com/golang/go1.12.1.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.12.1.linux-amd64.tar.gz
echo 'export PATH=$PATH:/usr/local/go/bin' >> /etc/profile
echo 'export GOPATH=$HOME/gopath' >> /etc/profile
source /etc/profile
cd $HOME
mkdir -p gopath/src/github.com/sodafoundation/api
cd gopath/src/github.com/sodafoundation/api
cp -r ${BASE_DIR}/* .
make ubuntu-dev-setup && make docker
cp cmd/osdsapiserver/osdsapiserver ${BASE_DIR}/cmd/osdsapiserver
